package cn.iocoder.yudao.module.api.product.evaluation.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.Valid;
import jakarta.validation.constraints.AssertTrue;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;

import java.util.List;

/**
 * 评论创建请求 DTO
 *
 * @author HUIHUI
 */
@Data
@Valid
public class ProductEvaluationCreateReqDTO {

    @Schema(description = "订单项编号。订单编号、订单项编号必须传一个，优先级依次为：orderItemId、orderId", example = "1")
    private Long orderItemId;

    @Schema(description = "订单编号。订单编号、订单项编号必须传一个，优先级依次为：orderItemId、orderId", example = "1")
    private Long orderId;

    @SuppressWarnings("unused")
    @AssertTrue(message = "订单编号、订单项编号不能同时为空")
    public boolean validate() {
        return (orderId != null && orderId > 0) || (orderItemId != null && orderItemId > 0);
    }

    @Schema(description = "评论内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "穿起来非常丝滑凉快")
    @NotNull(message = "评论内容不能为空")
    private String content;

    @Schema(description = "综合评分星级：1-5", example = "5")
    private Integer scores;

    @Schema(description = "描述评分星级：1-5", example = "5")
    private Integer descriptionScores;

    @Schema(description = "服务评分星级：1-5", example = "5")
    private Integer benefitScores;

    @Schema(description = "评论图片地址数组，最多上传 9 张")
    @Size(max = 9, message = "评论图片地址数组长度不能超过 9 张")
    private List<String> picUrls;

    @Schema(description = "是否匿名", example = "false")
    private Boolean anonymous;

}
